package com.ody.util.code.model;

import java.util.List;
import java.util.Properties;

import org.springframework.beans.factory.InitializingBean;

import com.google.common.collect.Lists;

public abstract class AbstractModelProvider implements IModelProvider, InitializingBean {
	private List<Model> modelList;
	private Properties properties;

	@Override
	public void afterPropertiesSet() throws Exception {
		if (properties != null) {
			if (modelList == null) {
				modelList = Lists.newArrayListWithExpectedSize(properties.size());
			}
			for (String key : properties.stringPropertyNames()) {
				modelList.add(new Model(key, properties.get(key)));
			}
		}
	}

	public Properties getProperties() {
		return properties;
	}
	public void setProperties(Properties modelProperties) {
		this.properties = modelProperties;
	}
	public List<Model> getModelList() {
		return modelList;
	}
	public void setModelList(List<Model> modelList) {
		this.modelList = modelList;
	}
	
}
